<?php session_start(); $_SESSION['page'] = 'admin';?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN">

<html>

   <head>
      <title>Administrator List</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
      <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>

       <table width='80%' align='center' class='content'>
        <tr><td colspan='2'><img src='images/banner.jpg'></td></tr>
        <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
        <tr class='menuborder'><td width='90%'><img src='images/adminlist.png'></td><td><?php  require('buttons.php'); ?></td></tr>
        <tr><td colspan='2' class='bodyborder'>
            <table align='center' width='70%'>
                <tr><td height='30'></td></tr>
                <tr><td>
                    <?php
                        require('db_connection.php');
                        $userType = $_COOKIE['userType'];
                        
                          if($userType == 'superadministrator')
                            {
                                $query = "SELECT * FROM tbladmin ORDER BY userType";
                            }
                          else
                            {
                                $libraryNo = $_COOKIE['libraryNo'];
                                $query = "SELECT * FROM tbladmin WHERE libraryNo=$libraryNo and userType='administrator' or userType='staff'";
                            }
                            
                        $result = mysql_query($query);
                        echo "<table class='listborder' align='center' cellspacing='0' cellpadding='3'><tr class='listtable'><th>User Name</th><th>User Type</th></tr>";
                        while ($row = mysql_fetch_array($result))
                        {
                             $adminID = $row['adminID'];
                             $userName = $row['userName'];
                             $userType = $row['userType'];
                             $libraryNo = $row['libraryNo'];
                             echo "<tr><td width='20%' class='listborder'><a href=adminedit.php?adminID=$adminID>$userName</a></td>";
                             echo "<td width='30%' class='listborder'>$userType</td></tr>";
                        }
                        echo "</table>";
                    ?>

                    </td>
                </tr>
                <tr><td height='30'></td></tr>
            </table>
            </td>
        </tr>
        <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
    </table>
  

   </body>
</html>
